home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------------------
-
- about.c
-
- This module presents the about box.
-
- Copyright © 1994-1995, Northwestern University.
-
- ----------------------------------------------------------------------------*/
-
- #include <stdio.h>
-
- #include "glob.h"
- #include "about.h"
- #include "text.h"
- #include "drawutil.h"
- #include "strutil.h"
- #include "windutil.h"
- #include "resutil.h"
- #include "help.h"
-
-
-
- #define kAboutText 128 /* resource id of about box text 'TEXT' resource */
-
- #define kEggID 129 /* resource id of Easter egg 'STR#' resource */
-
- #define kBigIconPictColor 128 /* resource id of big icon color picture */
- #define kBigIconPictBW 129 /* resource id of big icon B&W picture */
- #define kLogoPictColor 130 /* resource id of logo color picture */
- #define kLogoPictBW 131 /* resource id of logo B&W picture */
-
-
-
- static short gDrawEasterEgg = 0;
-
-
-
- /*----------------------------------------------------------------------------
- DrawPanel.
-
- Draw the panel area.
-
- Entry: wind = pointer to about window.
- ----------------------------------------------------------------------------*/
-
- static void DrawPanel (WindowPtr wind)
- {
- Rect r;
- CStr255 versStr;
- Str255 str;
- CStr255 fmt;
- TextStyle savedStyle;
- OSErr err = noErr;
- Str255 egg;
-
- GetPortTextStyle(&savedStyle);
- SetRect(&r, 50, 10, 134, 85);
- DrawColorPict(kBigIconPictColor, kBigIconPictBW, &r);
- SetRect(&r, 180, 17, 390, 56);
- DrawColorPict(kLogoPictColor, kLogoPictBW, &r);
-
- err = GetVersionString((StringPtr)versStr);
- p2cstr((StringPtr)versStr);
- if (err != noErr) goto exit;
- GetCString(kStrVersion, fmt);
- sprintf((char*)str, fmt, versStr);
- c2pstr((char*)str);
- MoveTo(183, 70);
- TextFont(systemFont);
- TextSize(12);
- DrawString(str);
- if (gDrawEasterEgg > 0) {
- MoveTo(183, 88);
- TextFont(applFont);
- TextSize(9);
- TextFace(bold | italic);
- GetIndString(egg, kEggID, gDrawEasterEgg);
- if (*egg == 0) {
- gDrawEasterEgg = 0;
- } else {
- DrawString(egg);
- }
- }
-
- exit:
-
- SetPortTextStyle(&savedStyle);
- }
-
-
-
- /*----------------------------------------------------------------------------
- DoAboutNewsWatcher
-
- Present the about box.
-
- Exit: function result = error code.
- ----------------------------------------------------------------------------*/
-
- OSErr DoAboutNewsWatcher (void)
- {
- Handle text;
- Str255 title;
- OSErr err = noErr;
- WindowPtr wind;
-
- gDrawEasterEgg = 0;
- GetPString(kStrAboutWindTitle, title);
- if (CheckTextWindowAlreadyOpen(title)) return noErr;
- err = MyGet1Resource('TEXT', kAboutText, &text);
- if (err != noErr) return err;
- err = MakeNewTextWindow(title, 100, DrawPanel, text, &wind);
- MyReleaseResource(text);
- return err;
- }
-
-
-
- /*----------------------------------------------------------------------------
- CheckAboutWindowEasterEgg
-
- Check for mouse down on big icon, display Easter egg.
-
- Entry: wind = pointer to text window.
- where = mouse down location, local coords.
- modifiers = keyboard modifiers.
- ----------------------------------------------------------------------------*/
-
- void CheckAboutWindowEasterEgg (WindowPtr wind, Point where, short modifiers)
- {
- Rect r;
- Str255 title, windTitle;
-
- if ((modifiers & optionKey) == 0) return;
- GetPString(kStrAboutWindTitle, title);
- GetWTitle(wind, windTitle);
- if (!EqualString(title, windTitle, false, false)) return;
- SetRect(&r, 50, 10, 134, 85);
- if (!PtInRect(where, &r)) return;
- gDrawEasterEgg++;
- SetRect(&r, 180, 76, wind->portRect.right, 93);
- InvalRect(&r);
- }
-
-
-
- /*----------------------------------------------------------------------------
- DoAboutWindowIconHelpBalloon
-
- Handle the help ballown for the big icon in the about window.
-
- Entry: wind = pointer to text window.
- where = current mouse location in local coordinates.
- ----------------------------------------------------------------------------*/
-
-
- void DoAboutWindowIconHelpBalloon (WindowPtr wind, Point where)
- {
- Rect r;
- Point tip;
-
- SetRect(&r, 50, 10, 134, 85);
- if (!PtInRect(where, &r)) return;
- SetPt(&tip, 120, 77);
- ShowHelpBalloon(tip, &r, 8);
- }
-